import xlrd

class Oper_Excel():
    def __init__(self,file_name=None,sheet_id=None):
        if file_name:
            self.file_name = file_name
            self.sheet_id = sheet_id
        else:
            self.file_name='../data/excel_01.xls'
            self.sheet_id = 0
        self.data = self.get_data()

    #获取sheet的内容
    def get_data(self):
        data = xlrd.open_workbook(self.file_name)
        table = data.sheets()[self.sheet_id]
        return table

    #获取单元格的行数
    def get_lines(self):
        table = self.data
        return table.nrows

    #获取某单元格的内容
    def get_cell_value(self,row,col):
        return self.data.cell_value(row,col)


if __name__ == '__main__':
    oper = Oper_Excel()
    print(oper.get_cell_value(1,2))
